package com.captain.leetcode.动态规划;

import com.sun.xml.internal.bind.v2.model.core.EnumLeafInfo;

import java.util.Arrays;

/**
 * Des:
 *
 * @author XL
 * @Date 2022/1/5 22:24
 */
public class 最长递增子序列300 {

    public int lengthOfLIS(int[] nums) {
        int len = nums.length;
        if (len == 1) return 1;
        int[] dp = new int[len + 1];
        Arrays.fill(dp, 1);
        int res = 0;
        for (int i = 0; i < len; i++) {
            for (int j = 0; j < i; j++) {
                if (nums[i] > nums[j]) {
                    dp[i] = Math.max(dp[j] + 1, dp[i]);
                }
            }
            res = Math.max(res, dp[i]);
        }
        return res;
    }

    public static void main(String[] args) {
        System.out.println(new 最长递增子序列300().lengthOfLIS(new int[]{10, 9, 2, 5, 3, 7, 101, 18}));

    }
}
